/*
 * TowerControlController.h
 *
 *  Created on: Sep 22, 2013
 *      Author: gonprieto
 */

#ifndef TOWERCONTROLCONTROLLER_H_
#define TOWERCONTROLCONTROLLER_H_

#include "../comunication/DTO/DTORunwayRelated.h"
#include "../comunication/DTO/DTOFlightRelated.h"
#include "../comunication/DTO/DTOFlightControler.h"
#include "../comunication/DTO/DTOFlightControlerRequest.h"
#include "../utils/Semaforo.h"
#include "../comunication/inbox/FlightControllerInbox.h"
#include "../comunication/inbox/TowerControlInbox.h"
#include "Proceso.h"

class TowerControlController : public Proceso{
public:
	TowerControlController(unsigned int controllersCount,unsigned int runwayCount);
	virtual ~TowerControlController();

	int run();

protected:
	void procesarMensaje(DTO* dto);

	//Operaciones que se invocan desde el procesamiento
	void finalizarOperaciones();
	void procesarMensajeRunway(DTORunwayRelated* dto);
	void procesarVuelo(DTOFlightRelated* dto);

	bool tengoProcesosOcupadas();
	int getFlightControllerToUse();

private:

    Semaforo* semRunways;

	bool isRunning;

	TowerControlInbox inbox;

	unsigned int controllersCount;
	unsigned int runwaysCount;

	//Los objetos de alto nivel que manejamos
	std::vector<FlightControllerInbox*> flightControllersInbox;

};

#endif /* TOWERCONTROLCONTROLLER_H_ */
